home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000159_icon-group-sender _Mon Jul 19 08:29:01 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id IAA05230
for icon-group-addresses; Mon, 19 Jul 1999 08:28:17 -0700 (MST)
Message-Id: <199907191528.IAA05230@baskerville.CS.Arizona.EDU>
From: "Frank Lhota" <lhotaf@lexma.meitech.com>
To: <icon-group@optima.CS.Arizona.EDU>, "Garry" <memphis@macconnect.com>
Subject: Re: Basename.icn in Library 9.3.2
Date: Mon, 19 Jul 1999 10:39:06 -0400
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
> I like the new version, it's the Basename that I know and love, but the
behavior has actually changed and the documentation doesn't reflect that (so
I don't know if the behavior is intended or not). The file documentation
says that
> # If no suffix is provided, the portion of the name up to the first
> # "." is returned.
>
> I think that that is no longer true and that the new Basename returns the
simple filename, with suffix, if no suffix is specified.
>
> Am I correct? (I'm an Icon newbie and I'm confused as to whether I'm
confused...)
> Is the behavior intended?
Yes, that is true. Obviously, the new version has no search for "." if
suffix is undefined or not present. The best way to verify this is by unit
testing, e.g.,
procedure main ( arg )
write ( basename ( arg [ 1 ], ( arg [ 2 ] | &null ) )
end
> Should the documentation be corrected?
>
That all depends on how we want basename to behave. If we actually want the
old behavior, we should correct the procedure instead. I think that the
original idea was to make basename mimic the Unix utility of the same name.
The latest version of basename does seem to match the Unix basename, so if
this is what is desired, we should update the documentation.
Here is how I would implement basename:
procedure basename(name, suffix) #: base name of file
local base
name ? {
while tab ( upto('/\\:') + 1 ) # get rid of path, if any
if ( base := tab ( -*\suffix ) ) & =suffix then return base
$ifdef OLD_STYLE
else return tab ( find ( "." ) | 0 )
$else # OLD_STYLE
else return tab ( 0 )
$endif # OLD_STYLE
}
end
To get the old behavior (cut off everything after the first "." if suffix is
null or not at the end of the name), define the symbol OLD_STYLE. Otherwise,
you'll get the Unix style, i.e. if the suffix is null or not at the end,
return everything past the path part.